odhcpd: remove the "legacy" option
authorDavid Härdeman <[email protected]>
Sun, 26 Oct 2025 09:19:14 +0000 (10:19 +0100)
committerÁlvaro Fernández Rojas <[email protected]>
Thu, 6 Nov 2025 07:24:51 +0000 (08:24 +0100)
LuCI has already been updated so that the "dhcpv4" option is exposed in
the UI and the option also gets set when the user clicks the "Set up
DHCP Server" button in the "DHCP Server" tab in the interfaces view.
Furthermore, there are instructions in the UI to enable the DHCPv4
server on a per-interface basis.

Finally, the odhcp defaults script (in the openwrt repo) also sets the dhcpv4
option, as necessary.

People who don't use LuCI but prefer the cmdline should presumably be able to
figure out that the dhcpv4 option needs to be set (if it isn't already), so
remove the "legacy" option.

This supersedes this PR:
https://github.com/openwrt/odhcpd/pull/275

Note that the "maindhcp" option is used by both dnsmasq and odhcpd to control
which of them handles DHCPv4, and is now exposed in the LuCI UI as well, so it
cannot be removed.

Signed-off-by: David Härdeman <[email protected]>
Link: https://github.com/openwrt/odhcpd/pull/294
Signed-off-by: Álvaro Fernández Rojas <[email protected]>
README.md
src/config.c

index 48ec641dd0f2b4c625f540f0d1f78a36bec94145..7f3d3479f68e21754331ea638a52d56d89cd43ef 100644 (file)
--- a/README.md
+++ b/README.md
@@ -61,7 +61,6 @@ and may also receive information from ubus
 
 | Option       | Type  |Default| Description |
 | :------------ | :---- | :----        | :---------- |
-| legacy       | bool  | 0     | Enable DHCPv4 if start but no dhcpv4 option set |
 | maindhcp     | bool  | 0     | Use odhcpd as the main DHCPv4 service |
 | leasefile    | string|       | DHCP/v6 lease/hostfile |
 | leasetrigger | string|       | Lease trigger script |
index 4bf8b2aa109fcecfc89d1f36aba3156cb8d50cb5..1821b529f346530b5e484451741f90a34b211871 100644 (file)
@@ -35,7 +35,6 @@ struct vlist_tree lease_cfgs = VLIST_TREE_INIT(lease_cfgs, lease_cfg_cmp,
 
 AVL_TREE(interfaces, avl_strcmp, false, NULL);
 struct config config = {
-       .legacy = false,
        .enable_tz = true,
        .main_dhcpv4 = false,
        .dhcp_cb = NULL,
@@ -206,7 +205,6 @@ const struct uci_blob_param_list lease_cfg_attr_list = {
 };
 
 enum {
-       ODHCPD_ATTR_LEGACY,
        ODHCPD_ATTR_MAINDHCP,
        ODHCPD_ATTR_LEASEFILE,
        ODHCPD_ATTR_LEASETRIGGER,
@@ -218,7 +216,6 @@ enum {
 };
 
 static const struct blobmsg_policy odhcpd_attrs[ODHCPD_ATTR_MAX] = {
-       [ODHCPD_ATTR_LEGACY] = { .name = "legacy", .type = BLOBMSG_TYPE_BOOL },
        [ODHCPD_ATTR_MAINDHCP] = { .name = "maindhcp", .type = BLOBMSG_TYPE_BOOL },
        [ODHCPD_ATTR_LEASEFILE] = { .name = "leasefile", .type = BLOBMSG_TYPE_STRING },
        [ODHCPD_ATTR_LEASETRIGGER] = { .name = "leasetrigger", .type = BLOBMSG_TYPE_STRING },
@@ -446,9 +443,6 @@ static void set_config(struct uci_section *s)
        uci_to_blob(&b, s, &odhcpd_attr_list);
        blobmsg_parse(odhcpd_attrs, ODHCPD_ATTR_MAX, tb, blob_data(b.head), blob_len(b.head));
 
-       if ((c = tb[ODHCPD_ATTR_LEGACY]))
-               config.legacy = blobmsg_get_bool(c);
-
        if ((c = tb[ODHCPD_ATTR_MAINDHCP]))
                config.main_dhcpv4 = blobmsg_get_bool(c);
 
@@ -1196,9 +1190,6 @@ int config_parse_interface(void *data, size_t len, const char *name, bool overwr
                iface->dhcpv4_start.s_addr = htonl(blobmsg_get_u32(c));
                iface->dhcpv4_end.s_addr = htonl(ntohl(iface->dhcpv4_start.s_addr) +
                                                        LIMIT_DEFAULT - 1);
-
-               if (config.main_dhcpv4 && config.legacy)
-                       iface->dhcpv4 = MODE_SERVER;
        }
 
        if ((c = tb[IFACE_ATTR_LIMIT]))
@@ -1239,12 +1230,10 @@ int config_parse_interface(void *data, size_t len, const char *name, bool overwr
 
        if ((c = tb[IFACE_ATTR_DHCPV4])) {
                if ((mode = parse_mode(blobmsg_get_string(c))) >= 0) {
-                       if (config.main_dhcpv4) {
-                               iface->dhcpv4 = mode;
+                       iface->dhcpv4 = config.main_dhcpv4 ? mode : MODE_DISABLED;
 
-                               if (iface->dhcpv4 != MODE_DISABLED)
-                                       iface->ignore = false;
-                       }
+                       if (iface->dhcpv4 != MODE_DISABLED)
+                               iface->ignore = false;
                } else
                        error("Invalid %s mode configured for interface %s",
                              iface_attrs[IFACE_ATTR_DHCPV4].name, iface->name);